﻿using BootstrapBlazor.Components;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Extensions;
using BPM.Web.Shared.Dependencies;
namespace BPM.Web.Shared.Service;

[Scoped(typeof(ISysDictTypeService))]
public class SysDictTypeService : BaseService, ISysDictTypeService
{
    private readonly IDictTypeClient _dictTypeClient;
    public SysDictTypeService(IDictTypeClient dictTypeClient, ToastService toast) : base(toast)
        => _dictTypeClient = dictTypeClient;
    
    public Task<bool> AddAsync(SysDictType input)
        => ExecuteAsync(_dictTypeClient.AddAsync(input.Adapt<AddDictTypeInput>()));

    public Task<bool> DeleteAsync(IEnumerable<SysDictType> input)
        => DeleteAsync(input.Select(x => _dictTypeClient.DeleteAsync(x.Adapt<DeleteDictTypeInput>())));

    public Task<QueryData<SysDictType>> PageAsync(DictTypePageInput input)
        => QueryAsync(_dictTypeClient.PageAsync(input));

    public Task<bool> EditAsync(SysDictType input)
        => ExecuteAsync(_dictTypeClient.EditAsync(input.Adapt<UpdateDictTypeInput>()));
}

